﻿using System;
using System.Collections.Generic;

namespace Agile.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    public interface IQuery
    {
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        List<TEntity> QueryMany<TEntity>(Action<TEntity, IDataReader> customMapper = null);
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        List<TEntity> QueryMany<TEntity>(Action<TEntity, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TList"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TList QueryMany<TEntity, TList>(Action<TEntity, IDataReader> customMapper = null) where TList : IList<TEntity>;
        /// <summary>
        /// 执行SQL查询语句并返回List集合
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <typeparam name="TList"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TList QueryMany<TEntity, TList>(Action<TEntity, dynamic> customMapper) where TList : IList<TEntity>;
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="list"></param>
        /// <param name="customMapper"></param>
        void QueryComplexMany<TEntity>(IList<TEntity> list, Action<IList<TEntity>, IDataReader> customMapper);
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="list"></param>
        /// <param name="customMapper"></param>
        void QueryComplexMany<TEntity>(IList<TEntity> list, Action<IList<TEntity>, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QuerySingle<TEntity>(Action<TEntity, IDataReader> customMapper = null);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QuerySingle<TEntity>(Action<TEntity, dynamic> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QueryComplexSingle<TEntity>(Func<IDataReader, TEntity> customMapper);
        /// <summary>
        /// 执行SQL查询语句并返回单个T对象
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="customMapper"></param>
        /// <returns></returns>
        TEntity QueryComplexSingle<TEntity>(Func<dynamic, TEntity> customMapper);
    }
}